#pragma once
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>

struct Client
{
    Client()
    {}

    Client(std::string ip,uint16_t port,std::string msg)
    :_ip(ip)
    ,_port(port)
    ,_msg(msg)
    {}  
    void Print() const
    {
        cout << _ip << ":" << _port << endl;
    }
    // 提供哈希计算
    // 客户端是通过ip+port唯一标识的！！
    size_t operator()(const Client& cli) const
    {
        return inet_addr(cli._ip.c_str()) + _port;
    }
    bool operator==(const Client& cli) const
    {
        return _ip == cli._ip && _port == cli._port;
    }

    std::string _ip;
    uint16_t _port;
    std::string _msg;
};
